{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  易扬\n",
    "+ 学号  0174922"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "贫困户\n",
      "                \n",
      "需要帮扶义务教育\n",
      "需要帮扶饮水安全\n",
      "需要帮扶肉蛋奶肉\n"
     ]
    }
   ],
   "source": [
    "class Poor():\n",
    "    def __init__(self,education,house,water,meat):\n",
    "        self.education = education\n",
    "        self.house = house\n",
    "        self.water = water\n",
    "        self.meat = meat\n",
    "    def assess_poor(self):\n",
    "        sum = 0\n",
    "        if self.education == False:\n",
    "            sum += 1 \n",
    "        if self.house == False:\n",
    "            sum += 1\n",
    "        if self.water  == False:\n",
    "            sum += 1\n",
    "        if self.meat == False:\n",
    "            sum += 1\n",
    "        if sum>2:\n",
    "            print('''贫困户\n",
    "                ''')\n",
    "        else:\n",
    "            print(\"不是贫困户\")\n",
    "    def help_poor(self):\n",
    "        sum = 0\n",
    "        if self.education == False:\n",
    "            sum += 1 \n",
    "        if self.house == False:\n",
    "            sum += 1\n",
    "        if self.water  == False:\n",
    "            sum += 1\n",
    "        if self.meat == False:\n",
    "            sum += 1\n",
    "        if sum>2:\n",
    "            if self.education == False:\n",
    "                print(\"需要帮扶义务教育\")\n",
    "            if self.house == False:\n",
    "                print(\"需要帮扶住房安全\")\n",
    "            if self.water  == False:\n",
    "                print(\"需要帮扶饮水安全\")\n",
    "            if self.meat == False:\n",
    "                print(\"需要帮扶肉蛋奶肉\")\n",
    "        else:\n",
    "            print(\"\\n不需要帮扶\")\n",
    "        \n",
    "       \n",
    "        \n",
    "        \n",
    "        \n",
    "one_people = Poor(True,True,False,False)\n",
    "two_people = Poor(True,True,False,True)\n",
    "three_people = Poor(False,True,False,False)\n",
    "\n",
    "three_people.assess_poor()\n",
    "three_people.help_poor()\n",
    "            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "狗子 BMI可能偏大\n",
      "燕儿 体重正常\n"
     ]
    }
   ],
   "source": [
    "class weight():\n",
    "    def __init__(self,name,scores,sleep):\n",
    "        self.name = name\n",
    "        self.scores = scores\n",
    "        self.sleep = sleep\n",
    "    def forecast_weight(self):\n",
    "        if int(self.scores)>90 and int(self.sleep)<6:\n",
    "            print(self.name+\" BMI可能偏大\")\n",
    "        else:\n",
    "            print(self.name+\" 体重正常\")\n",
    "one_person = weight(\"伟鹏\",90,8)\n",
    "two_person = weight(\"狗子\",95,4)\n",
    "three_person = weight(\"燕儿\",80,5)\n",
    "\n",
    "two_person.forecast_weight()\n",
    "three_person.forecast_weight()\n",
    "                "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "狗子 趋于正常\n",
      "燕儿 体重正常\n"
     ]
    }
   ],
   "source": [
    "class information(weight):\n",
    "    def __init__(self,name,scores,sleep,run_time):\n",
    "        super().__init__(name,scores,sleep)\n",
    "        self.run_time = run_time\n",
    "    def forecast_weight(self):\n",
    "        if int(self.scores)>90 and int(self.sleep)<6 :\n",
    "            if self.run_time>30:\n",
    "                print(self.name+\" 趋于正常\")\n",
    "            else:\n",
    "                print(self.name+\" BMI可能偏大\")\n",
    "        else:\n",
    "            print(self.name+\" 体重正常\")\n",
    "            \n",
    "one_person = information(\"伟鹏\",90,8,50)\n",
    "two_person = information(\"狗子\",95,4,50)\n",
    "three_person = information(\"燕儿\",80,5,20)\n",
    "\n",
    "two_person.forecast_weight()\n",
    "three_person.forecast_weight()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
